#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Experimental/Finitedifferences/FdmLinearOpComposite.h>
#pragma unmanaged 
#include <ql\experimental\finitedifferences\fdmblackscholesop.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Math;
using namespace Cephei::QL::Processes;
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Experimental { namespace Finitedifferences {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IFdmBlackScholesOp
	public ref class CFdmBlackScholesOp : 
            public CFdmLinearOpComposite,
            public Cephei::QL::Experimental::Finitedifferences::IFdmBlackScholesOp
	{
	protected: 
		boost::shared_ptr<QuantLib::FdmBlackScholesOp>* _ppFdmBlackScholesOp;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::FdmBlackScholesOp>* _phFdmBlackScholesOp;
#endif
		Object^ _FdmBlackScholesOpOwner;     // reference to object that manages the storage for this object
	internal:
		CFdmBlackScholesOp (Cephei::QL::Experimental::Finitedifferences::IFdmMesher^ mesher, Cephei::QL::Processes::IGeneralizedBlackScholesProcess^ process, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ localVol, Microsoft::FSharp::Core::FSharpOption<Double>^ illegalLocalVolOverwrite);
        CFdmBlackScholesOp (boost::shared_ptr<QuantLib::FdmBlackScholesOp>& childNative, Object^ owner);
        CFdmBlackScholesOp (QuantLib::FdmBlackScholesOp& childNative, Object^ owner);
        CFdmBlackScholesOp (CFdmBlackScholesOp^ copy);
        CFdmBlackScholesOp (System::Type^ t);
#ifdef STRUCT
        CFdmBlackScholesOp (QuantLib::FdmBlackScholesOp childNative);
#endif       
#ifdef HANDLE
		CFdmBlackScholesOp (QuantLib::Handle<QuantLib::FdmBlackScholesOp>& childNative, Object^ owner);
		CFdmBlackScholesOp (QuantLib::Handle<QuantLib::FdmBlackScholesOp> childNative);
#endif
		virtual ~CFdmBlackScholesOp ();
		!CFdmBlackScholesOp ();

	internal:
		QuantLib::FdmBlackScholesOp& GetReference ();
		boost::shared_ptr<QuantLib::FdmBlackScholesOp>& GetShared ();
		QuantLib::FdmBlackScholesOp* GetPointer ();
        void SetFdmBlackScholesOp (boost::shared_ptr<QuantLib::FdmBlackScholesOp> native)
        {
            if (_ppFdmBlackScholesOp != NULL)
                delete _ppFdmBlackScholesOp;
            _ppFdmBlackScholesOp = new boost::shared_ptr<QuantLib::FdmBlackScholesOp> (native);
            SetFdmLinearOpComposite (boost::dynamic_pointer_cast<QuantLib::FdmLinearOpComposite> (*_ppFdmBlackScholesOp));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::FdmBlackScholesOp>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
		virtual Cephei::QL::Experimental::Finitedifferences::IFdmBlackScholesOp^ SetTime (Double t1, Double t2) ;
        property UInt64 Size 
        {
		    virtual UInt64 get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CFdmBlackScholesOp_Factory : public System::MarshalByRefObject,  public IFdmBlackScholesOp_Factory
	{
	public:
        virtual IFdmBlackScholesOp^ Create (Cephei::QL::Experimental::Finitedifferences::IFdmMesher^ mesher, Cephei::QL::Processes::IGeneralizedBlackScholesProcess^ process, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ localVol, Microsoft::FSharp::Core::FSharpOption<Double>^ illegalLocalVolOverwrite);
    };
   
/*Cephei*/ } /*QL*/ } /*Experimental*/ } /*Finitedifferences */}
